-
-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(organizations): create endpoints to handle organization invitations TASK-969 #5395
feat(organizations): create endpoints to handle organization invitations TASK-969 #5395
Conversation
092d932
to
64a2b55
Compare
64a2b55
to
1139076
Compare
1139076
to
c28ad37
Compare
@rajpatel24 Wuld that whole invite object be present in |
@magicznyleszek No, the invite object would not be present there. I don't think it's necessary since The |
31ac077
to
ea9a6bd
Compare
32b1431
to
5394358
Compare
|
||
{% trans "All projects, submissions, data storage, transcription and translation usage for their projects will be transferred to you." %} | ||
|
||
{% trans "Note: You will continue to have permissions to manage these projects until the user permissions are changed." %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this sentence should be here since that's the sender who receives this message.
(Please fix HTML template too)
kobo/apps/organizations/templates/emails/registered_user_invite.txt
Outdated
Show resolved
Hide resolved
…atuses from the model
kobo/apps/organizations/models.py
Outdated
@@ -365,21 +376,26 @@ def send_invite_email(self): | |||
email_message = EmailMessage( | |||
to=to_email, | |||
subject=t( | |||
f"You're invited to join {organization_name}'s organization" | |||
), | |||
f"You're invited to join ##organization_name## organization" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not need to be an f-string anymore
kobo/apps/organizations/models.py
Outdated
f"You're invited to join {organization_name}'s organization" | ||
), | ||
f"You're invited to join ##organization_name## organization" | ||
).replace('##organization_name##', organization_name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use your utility replace_placeholders()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also I have moved the utility function to a new file, as it is a generic utility not specific to the organizations app.
… refine permissions
… github.com:kobotoolbox/kpi into task-969-create-endpoints-to-handle-org-invitations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ons TASK-969 (#5395) ### 📣 Summary Implemented endpoints for organization invitations, allowing organization owners to invite existing users or unregistered users to join their organization. The invitee can either accept or decline the invitation. If the invitee accepts, their assets will be transferred to the organization. ### 📖 Description - Organization owners can send invitations to users (both registered and unregistered) via email or username. - The invitee can accept or decline the invitation. If accepted, the invitee's assets will be transferred to the organization owner. > POST https://[kpi]/api/v2/organizations/org_12345/invites/ - Create organization invites for registered and unregistered users. - Set the role for which the user is being invited - (Choices: `member`, `admin`). Default is `member`. Payload: ``` { "invitees": ["demo14", "[email protected]", "[email protected]"], "role": "admin" } ``` Response: ``` [ { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/7a4f9a3b-9112-43cc-a6ae-bb4a6583b4b2/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "pending", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "demo14" }, { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/6746121a-7a87-4c2d-9994-85e38d8cff65/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "pending", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "demo13" }, { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/2af706a9-4f67-4145-a0d3-8d66fbc77a19/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "pending", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "[email protected]" } ] ``` > GET https://[kpi]/api/v2/organizations/org_12345/invites/ Response: ``` { "count": 3, "next": null, "previous": null, "results": [ { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/6746121a-7a87-4c2d-9994-85e38d8cff65/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "pending", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "demo13" }, { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/7a4f9a3b-9112-43cc-a6ae-bb4a6583b4b2/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "pending", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "demo14" }, { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/2af706a9-4f67-4145-a0d3-8d66fbc77a19/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "pending", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "[email protected]" } ] } ``` > PATCH https://[kpi]/api/v2/organizations/org_12345/invites/7a4f9a3b-9112-43cc-a6ae-bb4a6583b4b2/ - Update an organization invite to accept, decline, cancel, expire, or resend. Payload: ``` { "status": "accepted" } ``` Response: ``` { "url": "http://kf.kobo.local/api/v2/organizations/org_12345/invites/7a4f9a3b-9112-43cc-a6ae-bb4a6583b4b2/", "invited_by": "http://kf.kobo.local/api/v2/users/gtl_raj/", "status": "accepted", "invitee_role": "admin", "created": "2025-01-06T13:01:40Z", "modified": "2025-01-06T13:01:40Z", "invitee": "demo14" } ``` > DELETE https://[kpi]/api/v2/organizations/org_12345/invites/7a4f9a3b-9112-43cc-a6ae-bb4a6583b4b2/ - Organization owner or admin can delete an organization invite. Response: 204 --------- Co-authored-by: Olivier Leger <[email protected]>
🗒️ Checklist
<type>(<scope>)<!>: <title> TASK-1234
frontend
orbackend
unless it's global📣 Summary
Implemented endpoints for organization invitations, allowing organization owners to invite existing users or unregistered users to join their organization. The invitee can either accept or decline the invitation. If the invitee accepts, their assets will be transferred to the organization.
📖 Description
member
,admin
). Default ismember
.Payload:
Response:
Response:
Payload:
Response:
Response: 204